//
//  AllPageTableViewCell.m
//  MoGuRadio
//
//  Created by dlios on 15/6/4.
//  Copyright (c) 2015年 mogu.com 蘑菇科技. All rights reserved.
//

#import "AllPageTableViewCell.h"

@implementation AllPageTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.mainImageView = [[UIImageView alloc] init];
        self.mainImageView.backgroundColor = [UIColor lightGrayColor];
        self.mainImageView.layer.cornerRadius = 10;
        self.mainImageView.layer.masksToBounds = YES;
        self.mainImageView.userInteractionEnabled = YES;
        [self.contentView addSubview:self.mainImageView];
        [_mainImageView release];
        
        
        self.playImageView = [[UIImageView alloc] init];
        self.playImageView.image = [UIImage imageNamed:@"bofang.png"];
        self.playImageView.userInteractionEnabled = YES;
        [self.contentView addSubview:self.playImageView];
        [_playImageView release];
        
        
        self.focusImageView = [[UIImageView alloc] init];
        self.focusImageView.image = [UIImage imageNamed:@"iconfont-man.png"];
        [self.contentView addSubview:self.focusImageView];
        [_focusImageView release];
        
        
        self.listenImageView = [[UIImageView alloc] init];
        self.listenImageView.image = [UIImage imageNamed:@"listen.png"];
        [self.contentView addSubview:self.listenImageView];
        [_listenImageView release];
        
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.font = [UIFont boldSystemFontOfSize:15];
        [self.titleLabel sizeToFit];
        [self.contentView addSubview:self.titleLabel];
        [_titleLabel release];
        
        
        self.desLabel = [[UILabel alloc] init];
        self.desLabel.font = [UIFont systemFontOfSize:12];
        [self.desLabel sizeToFit];
        
        // 以边界为止 (保留整个字符)
        self.desLabel.lineBreakMode = NSLineBreakByCharWrapping;
        [self.contentView addSubview:self.desLabel];
        [_desLabel release];
        
        
        self.likeLabel = [[UILabel alloc] init];
        self.likeLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:self.likeLabel];
        [_likeLabel release];
        
        
        self.focusLabel = [[UILabel alloc] init];
        self.focusLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:self.focusLabel];
        [_focusLabel release];
        
        
        self.listenLabel = [[UILabel alloc] init];
        self.listenLabel.font = [UIFont systemFontOfSize:10];
        [self.contentView addSubview:self.listenLabel];
        [_listenLabel release];
        
        
        self.addButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.contentView addSubview:self.addButton];
        
        
    }
    
    
    return self;
    
    
}



- (void)layoutSubviews
{
    
    [super layoutSubviews];
    
    CGFloat width = self.contentView.bounds.size.width / 5;
    CGFloat height = self.contentView.bounds.size.height;
    
    self.mainImageView.frame = CGRectMake(8 * kXWidth, 8 * kYHeight, width, height - 10);
    self.playImageView.frame = CGRectMake(width / 3, height / 4, width / 1.5, height / 2.1);
    self.titleLabel.frame = CGRectMake(width + 20 * kXWidth, 3 * kYHeight, width * 3, height / 3);
    self.desLabel.frame = CGRectMake(width + 20 * kXWidth, height / 2.8, width * 3 - 8, height / 4);
    
    self.addButton.frame = CGRectMake(width * 4.22, height / 4.8, width / 2.5, height / 3);
    self.likeLabel.frame = CGRectMake(width * 4.25, height / 2.0, width, height / 4);
    
    self.focusImageView.frame = CGRectMake(width + 20 * kXWidth, height / 1.4, width / 6, height / 7);
    self.focusLabel.frame = CGRectMake(width * 1.5, height / 1.5, width * 2, height / 4);
    self.listenImageView.frame = CGRectMake(width * 2.8, height / 1.4, width / 4, height / 5);
    self.listenLabel.frame = CGRectMake(width * 3.1, height / 1.46, width * 2, height / 4);
}



- (void)dealloc
{
    [_playImageView release];
    [_likeLabel release];
    [_mainImageView release];
    [_focusImageView release];
    [_listenImageView release];
    [_titleLabel release];
    [_focusLabel release];
    [_listenLabel release];
    [super dealloc];
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
